package com.housekeeping.housekeeping.advertisingmanagement.controller.product;/*
 * @author  pyh
 * @date  2021/1/22 0022 下午 9:49
 * @version 1.0
 * @since JDK1.8_241
 */

import com.housekeeping.housekeeping.advertisingmanagement.service.ProductService;
import com.housekeeping.housekeeping.advertisingmanagement.service.impl.ProductServiceImpl;
import com.housekeeping.housekeeping.advertisingmanagement.utils.ResponseEntitys;
import com.housekeeping.housekeeping.advertisingmanagement.utils.ResponseUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/product/proDel")
public class ProDeleteController extends HttpServlet {
    private ProductService ps = new ProductServiceImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //转码
        resp.setContentType("text/html;charset=utf-8");
        req.setCharacterEncoding("utf-8");
        //接收将要删除的id
        int id = Integer.parseInt(req.getParameter("id"));
        int i = ps.del(id);
        ResponseEntitys<Object> entity = null;
        if (i > 0){
            entity = ResponseEntitys.success(null);
        }else {
            entity = ResponseEntitys.error(400006, "删除失败");
        }
        ResponseUtils.resp(resp,entity);
    }
}
